package com.kfm.base.collection;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Demo02 {

    public static void main(String[] args) {
        System.out.println(0.1  + 0.2);

        // 精度运算
        BigDecimal decimal = new BigDecimal("0.1");
        BigDecimal decimal1 = new BigDecimal("0.2");

        BigDecimal add = decimal.add(decimal1);
        System.out.println(add.doubleValue());

        // 以分为单位
        long num = 10;
        long num1 = 20;

        System.out.println((num + num1) / 100.0);


//        BigDecimal divide = decimal1.divide(decimal1, 2, 3);
        BigDecimal divide = decimal.divide(decimal1, 2, RoundingMode.FLOOR);
        System.out.println(divide);
    }
}
